<?php
	$table="account";
	include("../../include/dbconnect.php");
	$page=(int)$_POST["page"];
	if($page==0) $page=1;
	
	$rp=(int)$_POST["rp"];
	if($rp==0) $rp=15;
	
	$sidx = $_POST['sortname'];  
	$sord = $_POST['sortorder'];  
	if($sidx=="") $sidx =1;  

	$query = $_POST['query'];
	$qtype = $_POST['qtype'];
	
	$where = "";
	if ($query) $where = " WHERE $qtype LIKE '%$query%' ";

	$result = mysql_query("SELECT COUNT(*) AS count FROM $table $where",$conn) ;
	$row = mysql_fetch_array($result,MYSQL_ASSOC);  
	$count = $row['count']; 
	mysql_free_result($result);
 
	$start = (($page-1) * $rp);
 
	$SQL = "SELECT $table.*,(select groups.ten from groups where groups.ma=$table.magrp) as tengroups FROM $table $where ORDER BY $sidx $sord LIMIT $start , $rp";  
	$result = mysql_query($SQL,$conn) or die("Lỗi hệ thống trong module $table".mysql_error());  
 

    header("Content-type: text/xml"); 
	echo "<?xml version='1.0' encoding='utf-8' ?>"; 
	echo "<rows>"; 
	echo "<page>".$page."</page>"; 
	echo "<total>".$count."</total>"; 
 
	while($row = mysql_fetch_array($result)) { 
		echo "<row id='". $row["un"]."'>"; 
		echo "<cell>".$row["un"]."</cell>"; 
		echo "<cell><![CDATA[". str_repeat("*",strlen($row["pwd"]))."]]></cell>"; 
		echo "<cell>".$row["magrp"]."</cell>"; 
		echo "<cell>".$row["tengroups"]."</cell>"; 
		echo "</row>"; 

	}
echo "</rows>"; 
mysql_free_result($result);
include("../../include/dbclose.php");
?>